package com.scs.application.modules.upms.login.token;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.scs.application.core.utils.DateUtils;
import com.scs.application.modules.upms.entity.User;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Date;
import java.util.List;

/**
 * @Description: 授权成功TOKEN
 */
@Data
@Accessors(chain = true)
public abstract class BaseAccessToken {

    @JsonIgnore
    private String accessToken;

    private String jti;

    private Long expiresIn;

    private String userId;

    private String openId;

    private String loginKey;

    /**
     * 是否需要更新密码，密码是初始密码或者密码已过期
     */
    private short needModify;

    private JSONObject userInfo;

    private List<User> userListVx;

    /**
     * 过期时间
     * @return
     */
    public Date getExpiredDate() {
        if(expiresIn == null) {
            return  null;
        }
        return DateUtils.addSeconds(new Date(), expiresIn.intValue());
    }

}
